import React from "react";
import { NavLink, Routes, Route } from "react-router-dom";

// import "./06-style.css";

const Home = () => <div>这是首页</div>;
const About = () => <div>这是关于页</div>;

const App = () => {
  return (
    <div>
      <h2>router-v6-导航高亮</h2>
      <ul>
        {/* 6版本删除了activeClass */}
        {/* 只能写style了，style可以写函数(return对象) */}
        {/* 这个函数可以接受一个对象，对象里面有isActive，表示当前这个navLink是否被选中 */}
        <li>
          <NavLink
            to="/home"
            style={({ isActive }) => {
              return isActive ? { color: "red" } : {};
            }}
          >
            首页
          </NavLink>
        </li>
        <li>
          <NavLink to="/about">关于页</NavLink>
        </li>
      </ul>

      <hr />

      <Routes>
        <Route path="/home" element={<Home></Home>}></Route>
        <Route path="/about" element={<About />}></Route>
        <Route path="*" element={<div>404 not found...</div>}></Route>
      </Routes>
    </div>
  );
};

export default App;
